public class Solution1 {
    public String soliution (String s) {
        int len = s.length();

        if (len < 2) {
            return s;
        }

        int maxLen = 1;
        int begin = 0;

        char[] charArray = s.toCharArray();

        for (int i = 0; i < len -1; i++) {
            for (int j = 0; j < len; j ++) {
                if ((j - i + 1 > maxLen) && isPalindormic(charArray, i, j)){
                    maxLen = j - i + 1;
                    begin = i;
                }
            }
        }
        return s.substring(begin, begin+maxLen);
    }

    public boolean isPalindormic (char[] charArray, int left, int right) {
        while (left < right) {
            if (charArray[left] != charArray[right]) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
